﻿/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A
 * copy of the license can be found at http://go.microsoft.com/fwlink/?LinkID=131993. If
 * you cannot locate the Microsoft Public License, please send an email to
 * mixon@microsoft.com. By using this source code in any fashion, you are agreeing to
 * be bound by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace MIXOnline.Descry
{
    public static class HelperMethods
    {

        static HelperMethods()
        {
        }

        /// <summary>
        /// Gets absolute coordinates of any UIElement relative to the origin (top left corner) of 
        /// the application
        /// </summary>
        /// <param name="uie">The UIElement whose position is being sought</param>
        /// <returns>A Point object with absolute x,y coordinates</returns>
        public static Point GetCoords(UIElement fromUie, UIElement toUie)
        {
            GeneralTransform gt = toUie.TransformToVisual(fromUie);
            return gt.Transform(new Point(0, 0));
        }

        public static double getX(Grid grid)
        {
            return Convert.ToDouble(grid.RenderTransform.GetValue(TranslateTransform.XProperty));
        }

        public static void setX(UIElement grid, Double value)
        {
            grid.RenderTransform.SetValue(TranslateTransform.XProperty, value);
        }
                
    }
}
